package controller;

import dao.Artist;
import model.ArtistModel;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class ArtistsServlet extends HttpServlet {
    private static final String ARTISTS_ATTRIBUTE = "artists";
    private static final String ARTISTS_VIEW = "view/artists.jsp";

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        ArtistModel artistModel = ArtistModel.getInstance();

        List<Artist> artists = artistModel.getArtists();
        request.setAttribute(ARTISTS_ATTRIBUTE, artists);

        RequestDispatcher view = request.getRequestDispatcher(ARTISTS_VIEW);
        view.forward(request, response);
    }
}
